package com.SB.controller;

import com.SB.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author 金园
 * @create 2022/10/14
 * @Description 新增用户
 * @className AddController
 * @packageName com.SB.controller
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("/add")
@Api(tags = "User增删改查",description = "操作redis数据库的数据")
public class UserController {

    @RequestMapping("/useradd")
    @ApiOperation(value = "保存key-value到redis的String结构中")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key",value = "数据的key",defaultValue = "test"),
            @ApiImplicitParam(name = "value",value = "数据的value",defaultValue = "test")
    })
    public void  UserAdd(@RequestBody() User user){
        System.out.println("新增 '" + user.getUsername() + "' 成功");
    }

    @RequestMapping("/userdalete")
    public void  UserDelete(@RequestParam(value = "name",required = false)String name,@RequestParam(value = "age",required = false) Integer age){
        System.out.println("刪除 '" +name + "' 成功");
    }

    @RequestMapping("/userfind")
    public void  UserFind(@RequestParam(value = "name",required = false)String name,@RequestParam(value = "age",required = false) Integer age){
        System.out.println("查找 '" +name + "' 成功");
    }

    @RequestMapping("/userupdate")
    public void  UserUpdate(@RequestParam(value = "name",required = false)String name,@RequestParam(value = "age",required = false) Integer age){
        System.out.println("更新 '" +name + "' 成功");
    }

}
